home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
utildsk
/
memry374.lha
/
memory-device
/
source
/
speed.c
< prev
Wrap
C/C++ Source or Header
|
1996-03-29
|
3KB
|
149 lines
/*
** $VER: speed.c 1.0 (23 Mar 1996)
**
** (C) Copyright 1996 Marius Gröger
** All Rights Reserved
**
** $HISTORY:
**
** 23 Mar 1996 : 001.000 : created
*/
#define DEBUG 0
/*F*/ /* includes */
#ifndef CLIB_ALIB_PROTOS_H
#include <clib/alib_protos.h>
#endif
#ifndef CLIB_EXEC_PROTOS_H
#include <clib/exec_protos.h>
#include <pragmas/exec_sysbase_pragmas.h>
#endif
#ifndef CLIB_DOS_PROTOS_H
#include <clib/dos_protos.h>
#include <pragmas/dos_pragmas.h>
#endif
#ifndef EXEC_MEMORY_H
#include <exec/memory.h>
#endif
#ifndef DOS_DOS_H
#include <dos/dos.h>
#endif
#ifndef __DEBUG_H
#include "debug.h"
#endif
#ifndef __COMPILER_H
#include "compiler.h"
#endif
/*E*/
/*F*/ /* imports */
IMPORT ASM VOID CopyMemWarp(REG(a0) VOID *src, REG(a1) VOID *dst, REG(d0) ULONG len);
IMPORT VOID exit(LONG);
IMPORT struct Library *DOSBase, *SysBase;
/*E*/
#define DEF_SIZE 512
#define DEF_NUMBER 1000
/*F*/ STATIC ULONG systime(VOID)
{
struct DateStamp ds;
DateStamp(&ds);
return (ULONG)(ds.ds_Days*24*60*60*TICKS_PER_SECOND +
ds.ds_Minute*60*TICKS_PER_SECOND +
ds.ds_Tick);
}
/*E*/
/*F*/ STATIC VOID usage(UBYTE *name)
{
Printf(
"Usage: %s [options]\n" \
"Options: -n <num> Copy <num> number of blocks\n" \
" -s <size> Set blocksize to <size>*512\n"
, name);
}
/*E*/
/*F*/ VOID SAVEDS STDARGS main(ULONG argc, UBYTE **argv)
{
LONG i;
LONG rc = RETURN_OK;
LONG number = DEF_NUMBER, size = DEF_SIZE;
for (i=1; i<argc; i++)
{
UBYTE *arg = argv[i];
if (*arg++ == '-')
{
switch(*arg++)
{
case 'n':
if (!StrToLong(arg, &number) || number <= 0)
{
usage(argv[0]);
rc = RETURN_FAIL;
}
break;
case 's':
if (!StrToLong(arg, &size) || size <= 0)
{
usage(argv[0]);
rc = RETURN_FAIL;
}
size *= 512;
break;
default:
Printf("Unknown option '%lc'\n",arg[-1]);
usage(argv[0]);
rc = RETURN_FAIL;
}
}
else
{
usage(argv[0]);
rc = RETURN_FAIL;
}
}
if (rc == RETURN_OK)
{
UBYTE *p1, *p2;
ULONG before, after;
p1 = AllocVec(size, MEMF_ANY);
p2 = AllocVec(size, MEMF_ANY);
Printf("Performing %ld times CopyMemWarp(0x%08lx, 0x%08lx, %ld)...",
number, p1, p2, size);
Flush(Output());
if (p1 && p2)
{
Forbid();
before = systime();
for (i = 0; i<number; i++)
CopyMemWarp(p1, p2, size);
after = systime();
Permit();
after -= before;
}
Printf("ready.\nOperation needed %ld seconds and %ld ticks\n",
after / TICKS_PER_SECOND, after % TICKS_PER_SECOND);
if (p1) FreeVec(p1);
if (p2) FreeVec(p2);
}
exit(rc);
}
/*E*/